<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="javax.jdo.Query" %>
<%@ page import="appnode.Node" %>
<%@ page import="appnode.Ratings" %>
<%@ page import="appnode.RateUtils" %>
<%@ page import="appnode.SearchNode" %>
<%@ page import="appnode.Link" %>
<%@ page import="appnode.Linktools" %>
<%@ page import="appnode.Interface" %>
<%@ page import="appnode.NodeRating" %>
<%@ page import="appnode.PMF" %>
<%@ page import="com.google.appengine.api.datastore.Key"%>
<%@ page import="com.google.appengine.api.datastore.KeyFactory;"%>

<html>
<head>
	<link rel="stylesheet" href="map.css" type="text/css" media="screen" title="mapcss"></link>
	<title>Edit your link</title>
	<script>
	//document.input.Name.value==""

	function checkform() {
		valid=true;
		if (document.input.freq.value=="" || document.input.protocol.value=="" || document.input.power.value==""){
			alert("Fill all fields");
			valid=false;	
		}
		else {
			var a = document.input.freq.value;
			var b = parseFloat(a);
			if (b<5480 || b>5720) {
				alert("The frequency is out of range");
				valid=false;
			}
		}
	return valid;
	}
	</script>
</head>
<body class="window">
<div class="openwindow">
<%
	PersistenceManager pm = PMF.get().getPersistenceManager();
	String keystr = request.getParameter("keystr");
	Key key = KeyFactory.stringToKey(keystr);
	Link link = pm.getObjectById(Link.class,key);
%>

Edit your link (<a href="javascript:load()">delete</a>)<p>

<form name="input" action="editlink" method="get" onsubmit="return checkform()">
<input type="hidden" name="keystr" value="<%=keystr%>"></input>
<input type="hidden" name="delete" value=""></input>  
Frequency (5480-5720): <input type="text" name="freq" value="<%=link.getFreq()%>"></input><p>
Protocol : <select name="protocol"><option value="802.11a">802.11a</optional></select><p>
<input type="submit" value="Save"/>
<input type='button' value='Cancel' onClick='self.close()'/>
</form>


<script>
function load() {
	var r=confirm("You want to delete the link!");
	if (r==true) {
		document.location.href = "editlink?delete=ok&keystr=<%=keystr%>"
	}
}
</script>
</div>
</body>
</html>